package com.demo.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author wangfengchen
 */
@Getter
public enum KycRejectEnum {

  DEFAULT(0, "默认值"),
  FINAL(1, "最终拒绝"),
  RETRY(2, "允许重复提交"),

  ;

  private final Integer code;

  /**
   * 描述
   */
  private final String desc;

  KycRejectEnum(Integer code, String desc) {
    this.code = code;
    this.desc = desc;
  }

  public static KycRejectEnum match(Integer code) {
    Optional<KycRejectEnum> target = Arrays.stream(KycRejectEnum.values()).filter(item -> code.equals(item.getCode()))
        .findFirst();
    return target.orElse(null);
  }

  public static KycRejectEnum match(String name) {
    Optional<KycRejectEnum> target = Arrays.stream(KycRejectEnum.values()).filter(item -> name.equalsIgnoreCase(item.name()))
        .findFirst();
    return target.orElse(null);
  }

}
